$(function(){
	//复选框操作
	$('input[type="checkbox"]').click(function(){
    	if($(this).is(':checked')){
            //当前为选中状态
    		var $id = $(this).val();
    		var $type = $('.type').val();
            $.ajax({
                type:'POST',
                dataType:'json',
                url:'/business/repertory/repertorytemp',
                data:{id:$id,type:$type,flag:1},
                success:function (data){
                    if(data.state==1){
                        $('.count em').text(data.count);
                    }else{
                        layer.alert(data.message, {icon: 5});
                    }
                }
            })    
        }else{
            //当前为不选中状态
        	var $id = $(this).val();
    		var $type = $('.type').val();
            $.ajax({
                type:'POST',
                dataType:'json',
                url:'/business/repertory/repertorytemp',
                data:{id:$id,type:$type,flag:2},
                success:function (data){
                    if(data.state==1){
                    	$('.count em').text(data.count);
                    }else{
                        layer.alert(data.message, {icon: 5});
                    }
                }
            })
        }
        
    });
	//取消按钮操作

	$('.cancel_one').click(function(){
		var $type = $('.type').val();
		$.ajax({
            type:'POST',
            dataType:'json',
            url:'/business/repertory/repertorytemp',
            data:{type:$type,flag:3},
            success:function (data){
                if(data.state==1){
                	if(data.type==-1){//入库
                		top.location.href='/business/repertoryinc/storage';
                	}
                	if(data.type==-2){//出库
                		top.location.href='/business/goodsdec/repertoryout';
                	}
                	
                }else{
                    layer.alert(data.message, {icon: 5});
                }
            }
        })
	});
	//确定操作
	$('.ok').click(function(){
		var $type = $('.type').val();
		if($type == -1){//入库
			top.location.href = '/business/repertoryinc/storage';
		}
		if($type == -2){//出库
			top.location.href = '/business/goodsdec/repertoryout';
		}
		
	});

});